<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : AudioSample : : getChannel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">

  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName"><A href="audiosample_class_audiosample.html">AudioSample</A></p>
    	<p class="methodName">getChannel</p>
    </td>
    <td class="mainText border-left">
    	<p class="memberSectionHeader">Description</p>
    	Gets the samples for the requested channel number as a float array. 
 Use either AudioSample.LEFT or AudioSample.RIGHT.
    	
    	<p class="memberSectionHeader">Signature</p>
    	<pre>float[] getChannel(int channelNumber)
</pre>
    	
    	
   <p class="memberSectionHeader">Parameters</p>
   
        <span class="parameterName">channelNumber</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">int: the channel you want the samples for</span><br/>
    
   
    	
   <p class="memberSectionHeader">Returns</p> 
   <p>float[]: the samples in the specified channel</p>
   
    	
    	<p class="memberSectionHeader">Related</p>
    	<A href="audiosample_class_audiosample.html">AudioSample</A><BR>

    	
    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  * This sketch demonstrates how to get a channel of audio from an AudioSample 
  * and then manipulate it to change the AudioSample after it has been loaded. 
  * &lt;p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/
  */

import ddf.minim.*;

Minim minim;
AudioSample jingle;

void setup()
{
  size(512, 200, P3D);

  minim = new Minim(this);
  
  jingle = minim.loadSample("jingle.mp3", 2048);
  // get the left channel of the audio as a float array
  // getChannel expects either AudioSample.LEFT or AudioSample.RIGHT as an argument
  float[] leftChannel = jingle.getChannel(AudioSample.LEFT);
  // now we are just going to reverse the left channel
  float[] reversed = reverse(leftChannel);
  System.arraycopy(reversed, 0, leftChannel, 0, leftChannel.length);
}

void draw()
{
  background(0);
  stroke(255);
  for(int i = 0; i &lt; jingle.bufferSize() - 1; i++)
  {
    line(i, 50 - jingle.left.get(i)*50, i+1, 50 - jingle.left.get(i+1)*50);
    line(i, 150 - jingle.right.get(i)*50, i+1, 150 - jingle.right.get(i+1)*50);
  }
  
  text("Press any key to trigger the sample.", 10, 20);
}

void keyPressed()
{
  jingle.trigger();
}</pre>
    	
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>
